//
//  UserInfo.m
//  lsOA
//
//  Created by 蓝水软件 on 16/7/25.
//  Copyright © 2016年 苏州蓝水有限公司. All rights reserved.
//

#import "UserInfo.h"

@implementation UserInfo
//获取用户名
+ (NSString *)getUserName{
    NSUserDefaults *defaults  = [NSUserDefaults standardUserDefaults];
    NSString  *UserName =  [defaults objectForKey:@"UserName"];

    return UserName;
}
//获取登录密码
+ (NSString *)getPassWord{
    NSUserDefaults *defaults  = [NSUserDefaults standardUserDefaults];
    NSString *passWord =  [defaults objectForKey:@"PassWord"];
    return passWord;
    
}
//获取用户ID
+ (NSString *)getUserID{
    NSUserDefaults *defaults  = [NSUserDefaults standardUserDefaults];
    NSString *userID =  [defaults objectForKey:@"ID"];
    return userID;


}

//获取用户部门
+ (NSString *)getDepName{
    NSUserDefaults *defaults  = [NSUserDefaults standardUserDefaults];
    NSString *DepName =  [defaults objectForKey:@"DepName"];
    return DepName;
}

//生日
+ (NSString *)getBirthday{
    NSUserDefaults *defaults  = [NSUserDefaults standardUserDefaults];
    NSString *string =  [defaults objectForKey:@"Birthday"];
    return string;
}

//公司
+ (NSString *)getDepartName{
    NSUserDefaults *defaults  = [NSUserDefaults standardUserDefaults];
    NSString *string =  [defaults objectForKey:@"DepartName"];
    return string;
}

//电子邮箱
+ (NSString *)getEmail{
    NSUserDefaults *defaults  = [NSUserDefaults standardUserDefaults];
    NSString *string =  [defaults objectForKey:@"Email"];
    return string;
}

////真实姓名
//+ (NSString *)getRealName{
//    NSUserDefaults *defaults  = [NSUserDefaults standardUserDefaults];
//    NSString *string =  [defaults objectForKey:@"realName"];
//    return string;
//
//
//}


//设置密码
+ (void)setPassWord:(NSString *)passWord{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:passWord forKey:@"PassWord"];
    [NSUserDefaults description];
    [UserInfo getPassWord];
}
/**
 *  存储用户信息到本地
 *
 *  @param userInfo 网络请求成功后，取到的用户信息
 */
+ (void)saveUserData:(NSDictionary *)userInfo{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:userInfo forKey:@"underInfoDic"];
   
    
    for (int i = 0; i < [userInfo allKeys].count; i++) {
        NSString *key = [[userInfo allKeys] objectAtIndex:i];
        NSString *value = [userInfo valueForKey:key];
        if ([value isEqualToString:@"<null>"]) {
            value = @"";
        }
        [defaults setObject:value forKey:key];
    }

    
}
@end
